package slh.favourite;

import java.sql.Timestamp;

public class Favourite {
    private int favoriteId;
    private String userId;
    private int contentId;
    private String contentType; // "movie" 或 "book"
    private Timestamp createdAt;

    // 无参构造器
    public Favourite() {
    }

    // 带参构造器
    public Favourite(int favoriteId, String userId, int contentId, String contentType, Timestamp createdAt) {
        this.favoriteId = favoriteId;
        this.userId = userId;
        this.contentId = contentId;
        this.contentType = contentType;
        this.createdAt = createdAt;
    }

    // Getter 和 Setter 方法
    public int getFavoriteId() {
        return favoriteId;
    }

    public void setFavoriteId(int favoriteId) {
        this.favoriteId = favoriteId;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public int getContentId() {
        return contentId;
    }

    public void setContentId(int contentId) {
        this.contentId = contentId;
    }

    public String getContentType() {
        return contentType;
    }

    public void setContentType(String contentType) {
        if (!"movie".equals(contentType) && !"book".equals(contentType)) {
            throw new IllegalArgumentException("contentType 必须是 'movie' 或 'book'");
        }
        this.contentType = contentType;
    }

    public Timestamp getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(Timestamp createdAt) {
        this.createdAt = createdAt;
    }

    // toString() 方法
    @Override
    public String toString() {
        return "Favorite{" +
                "favoriteId=" + favoriteId +
                ", userId='" + userId + '\'' +
                ", contentId=" + contentId +
                ", contentType='" + contentType + '\'' +
                ", createdAt=" + createdAt +
                '}';
    }
}